import request from '@/utils/request'
import store from '@/store/index.js' // store
import auth from '@/plugins/auth.js'
import {
	transformPostBody,
	transformRequestURL
} from "@/utils/requestParams.js";

// 查询老人信息列表
export function QueryRTInfoList_Role(UrlParams, body) {
	if (!auth.hasRole("admin")) { //没有admin权限的情况下添加请求条件
		body.queryParam.permanentDistrict = store.state.user.user.remark
	}
	return request({
		url: '/elder/rtInfo/page',
		method: 'post',
		params: transformRequestURL(UrlParams),
		data: transformPostBody(body)
	})
}

export function QueryRTInfoList(UrlParams, body) {
	return request({
		url: '/elder/rtInfo/page',
		method: 'post',
		params: transformRequestURL(UrlParams),
		data: transformPostBody(body)
	})
}

// 查询指定老人详细信息
export function getRTInfo(Id) {
	return request({
		url: '/elder/rtInfo/' + Id,
		method: 'get'
	})
}

// 新增老人信息
export function addRTInfo(data) {
	// console.log('addRTInfo',{
	//   url: '/elder/rtInfo/save',
	//   method: 'post',
	//   data: data
	// });
	return request({
		url: '/elder/rtInfo/save',
		method: 'post',
		data: data
	})
}

// 修改老人信息
export function updateRTInfo(data) {
	// console.log('updateRTInfo',{
	//   url: '/elder/rtInfo/update',
	//   method: 'post',
	//   data: data
	// });
	return request({
		url: '/elder/rtInfo/update',
		method: 'post',
		data: data
	})
}

// 删除老人信息
export function delRTInfo(Ids) {
	return request({
		url: '/elder/rtInfo/delete',
		method: 'delete',
		data: Ids
	})
}

//dev-api/system/administrativeDivisions/getAdministrativeDivisions
// 查询分级行政区域
export function getAdministrativeDivisions(UrlParams) {
	return request({
		url: '/system/administrativeDivisions/getAdministrativeDivisions',
		method: 'get',
		params: UrlParams,
		data: null
	})
}